<?php
namespace api\know\traits;

use think\facade\Log;

trait KnowTrait
{
    protected $host = 'http://43.138.63.117:89/';

    public function replaceHost($r)
    {
        return preg_replace('/(\/upload\/default\/\d+)/i', "$this->host$1", $r);
    }

    public function decodeContent($content)
    {
        return $c = htmlspecialchars_decode(htmlspecialchars_decode($content));
    }

    public function decodeAndReplaceHost($content)
    {
        $c = $this->decodeContent($content);
        return $this->replaceHost($c);
    }

    public function log($log)
    {
        Log::debug($log);
    }


}
